﻿<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="MvcForum.Net.Mvc.ViewPage" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    <%
        var _topic = ViewData["Topic"] as TopicEntity;
        //string _plainText = ForumContext.ToPlainText(_topic.TopicName);%>
    <%=Html.Title("{0} - {1}", _topic.TopicName, ForumContext.Configuration.ForumName)%>
    <%=Html.Keywords(_topic.Keywords)%>
    <%=Html.Description(_topic.Description)%>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <%
        
        var _topic = ViewData["Topic"] as TopicEntity;

        Html.RenderPartial("LogOn");

        Html.RenderPartial("Navigation");

        var _pageUrl = ForumContext.ThreadLink(_topic.TopicId, _topic.TopicName, "{0}");
        var _totalRows = Convert.ToInt32(ViewData["TotalRows"]);
        var _pageIndex = Convert.ToInt32(ViewData["PageIndex"]);

        var _pageRenderTemp = ForumContext.PageRender(_pageUrl, _pageIndex, ForumContext.Configuration.PostsPerPage, _totalRows);

        var _postLink = ForumContext.GetAbsoluteUrl(ForumUrls.POST);

        string _replyCmd = ForumContext.Encrypt((int)CommandType.Reply, _topic.TopicId);
        var _reply = string.Format("window.location='{0}?sessionId={1}'", _postLink, _replyCmd);
        var _newPost = string.Format("window.location='{0}?sessionId={1}'", _postLink, ForumContext.Encrypt((int)CommandType.NewPost, _topic.ForumId));
    
    %>
    <div class="white-space">
        <%=_pageRenderTemp %>
        <button class="button-icon" onclick="<%=_reply %>">
            <span class="icon-b icon-reply">&nbsp;</span> <span class="button-text">
                <%=ForumContext.GetText("Topics","Reply") %></span>
        </button>
        <button class="button-icon" onclick="<%=_newPost %>">
            <span class="icon-b icon-newtopic">&nbsp;</span> <span class="button-text">
                <%=ForumContext.GetText("Topics","NEW_TOPIC") %></span>
        </button>
    </div>
    <div class="fr-widget white-space">
        <div class="header">
            <%--<div class="fr-options">
            <a class="down-icon div-menu {target:'#topic_option_panel'}" href="javascript:void(0)">
                Lựa chọn</a>
        </div>--%>
            <div class="icon">
            </div>
            <h1>
                <%=Html.Encode(_topic.TopicName)%>
            </h1>
        </div>
    </div>
    <%  Html.RenderPartial("ThreadList", ViewData["ThreadList"]); %>
    <% if (ForumContext.Logined && (ForumContext.UserInfo.IsAdmin || ForumContext.UserInfo.IsModerated(_topic.ForumId)))
       {
           Html.RenderPartial("ModerationTools");
        }%>
    <div class="white-space">
        <%=_pageRenderTemp %>
        <button class="button-icon" onclick="<%=_reply %>">
            <span class="icon-b icon-reply">&nbsp;</span> <span class="button-text">
                <%=ForumContext.GetText("Topics","Reply") %></span>
        </button>
        <button class="button-icon" onclick="<%=_newPost %>">
            <span class="icon-b icon-newtopic">&nbsp;</span> <span class="button-text">
                <%=ForumContext.GetText("Topics","NEW_TOPIC") %></span>
        </button>
    </div>
    <%if (ForumContext.Logined)
      {%>
    <div class="fr-widget white-space">
        <div class="header">
            <div class="collapse collapse-close {collapseId:'#collapse_quick_post'}">
            </div>
            <div class="icon">
            </div>
            <span>
                <%=ForumContext.GetText("Topics", "QUICK_REPLY")%></span>
        </div>
        <div id="collapse_quick_post">
            <%using (Html.BeginForm("AddPost", "Forum", FormMethod.Post, new { @id = "QuickPost", @onRequest = "$.MvcForum.showLoading()", @onSuccess = "$.MvcForum.ajaxSuccess(msg)" }))
              {
            %>
            <%=Html.AntiForgeryTokenX("POST")%>
            <input type="hidden" value="<%= Html.Encode(_topic.TopicName)  %>" id="subject" name="subject" />
            <input type="hidden" value="<%=ForumContext.Encrypt((int)CommandType.Reply,_topic.ForumId,_topic.TopicId)%>"
                id="cmd" name="cmd" />
            <table cellpadding="0" cellspacing="1" width="100%">
                <tr>
                    <td class="table-cell">
                        <textarea name="message" id="message" cols="1" rows="1" class="tinymce {validate:{required:true,minlength:9}}"
                            style="height: 200px; width: 99%" mode="medium"></textarea>
                    </td>
                </tr>
                <tr>
                    <td class="table-cell">
                        <button class="button-icon" onclick="$.MvcForum.ajaxSubmit('QuickPost');return false;">
                            <span class="icon-b icon-reply">&nbsp;</span> <span class="button-text">
                                <%=ForumContext.GetText("Topics", "QUICK_REPLY")%></span>
                        </button>
                    </td>
                </tr>
            </table>
            <%
                }%>
        </div>
    </div>
   <%-- <script type="text/javascript">
//<![CDATA[

        window.Page_Load = function () {
            if (!window.MF_JS_LOADED) {
                window.setTimeout('Page_Load()', 100);

                return;
            };
            $.MvcForum.htmlEditor();
        };

        Page_Load();

     //]]>

    </script>--%>
    <%} %>
</asp:Content>
